﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CastleOfTheDisillusioned.Location;

namespace CastleOfTheDisillusioned {
	class Weapon {
		public CollisionSequence AttackAnimation = new CollisionSequence();

		public double Damage = 1;

		public void Update(double X, double Y, Direction Dir) {
			AttackAnimation.Update(X, Y, Dir);

			if (AttackAnimation.IsRunning()) {
				List<Enemy> enemies = Location_State.CurrentMap.GetEnemies();
				BoundingBox hitbox = AttackAnimation.GetCollision(X, Y, Dir);
				foreach (Enemy e in enemies) {
					if (!AttackAnimation.CollidedWith.Contains(e) && hitbox.CollidesWith(e)) {
						e.TakeDamage(Damage);
						AttackAnimation.CollidedWith.Add(e);
					}
				}
			}
		}

		public void Draw(double X, double Y, Direction Dir) {
			AttackAnimation.Draw(X, Y, Dir);
		}

		public bool IsAttacking() {
			return AttackAnimation.IsRunning();
		}

		public void Attack() {
			AttackAnimation.Play();
		}
	}
}
